﻿using System.Collections.Generic;
using FileLibrary.Enums;

namespace GeneticSharpDemo.Models
{
    /// <summary>
    /// 车组的检修任务单
    /// 按照股道类型统计检修任务时间在同一类股道上的总时间
    /// </summary>
    public class JobInfo
    {
        private readonly List<Proc> _proc;

        /// <summary>
        /// 工序总数量
        /// </summary>
        public int ProcCnt { get; }
        /// <summary>
        /// 车组名
        /// </summary>
        public string JobName { get; }
        /// <summary>
        /// 按照检修任务单的统计顺序，为后文的JobId唯一索引
        /// </summary>
        public int JobId { get; set; }
        ///// <summary>
        ///// 工序及作业时间
        ///// </summary>
        //public List<int> Info { get; set; }
        /// <summary>
        /// 车组时间窗起始
        /// </summary>
        public int StartTime { get; set; } = 0;
        /// <summary>
        /// 是否为入所车，以开行单的到达时间判断
        /// </summary>
        public bool DepotIn { get; set; } = false;
        /// <summary>
        /// 车组时间窗终止
        /// </summary>
        public int EndTime { get; set; } = 0;
        /// <summary>
        /// 是否为出所车，以开行单的出发时间判断
        /// </summary>
        public bool DepotOut { get; set; } = false;
        ///// <summary>
        ///// 工序指定股道
        ///// </summary>
        //public List<string> TrackNames { get; set; }
        /// <summary>
        /// 工序信息，根据股道配置的功能类型
        /// </summary>
        public List<ProcInfo> ProcInfos { get; set; }

        public TrainGroupTypeEnum TrainGroupType { get; set; }

        public JobInfo(string jobName, List<Proc> proc)
        {
            _proc = proc;
            ProcCnt = proc.Count;
            JobName = jobName;
            //Info = new List<int>(procCnt);
            //TrackNames = new List<string>(procCnt);
            ProcInfos = new List<ProcInfo>();
            for (int i = 0; i < ProcCnt; i++)
            {
                //Info.Add(i);//工序i，从0开始
                //Info.Add(0);//工作作业时间

                //TrackNames.Add(string.Empty);//工作股道
                ProcInfos.Add(new ProcInfo(i, _proc[i]));
            }
        }

        public override string ToString()
        {
            return $"{JobName}-{TrainGroupType}-{DepotIn}-{DepotOut}-{StartTime}-{EndTime}";
        }
    }
}